package datasv.teacherQuery_datasv;

import java.util.Date;

import data.datafactory.DatabaseOperator;
import po.TeacherPO;

public class GetTeacher {
	public static void main(String[] args) {
		System.out.println(new GetTeacher().getTeacher("001132003"));
	}
	public TeacherPO getTeacher(String id){
		return getInSql(id);
	}
	private TeacherPO getInSql(String id){
		DatabaseOperator op=new DatabaseOperator("college"+id.substring(0,3));
		if(!op.ifDatabaseExist()||!op.ifIDExist("teacher_list", id)){
			return null;
		}
		String tID=id;
		String n=op.getOneInform(id, "teacher_list", "name");
		String collegeId=op.getOneInform(id, "teacher_list", "collegeID");
		int year=Integer.parseInt(op.getOneInform(id, "teacher_list", "workStartYear"));
		String[] m=op.getOneInform(id, "teacher_list", "birthday").split("/");
		Date birthday=new Date(Integer.parseInt(m[0]),Integer.parseInt(m[1]),Integer.parseInt(m[2]));
		return new TeacherPO(tID, n, collegeId, year, birthday);
	}
}
